Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Children array error #1026

Merged
merged 6 commits into from
Nov 27, 2019
Merged

Children array error #1026

merged 6 commits into from
Nov 27, 2019

Conversation

alexcjohnson
Copy link
Collaborator

@alexcjohnson alexcjohnson commented Nov 22, 2019

Trying to give a more helpful error message than users encounter today, like #1024, when forgetting to wrap children in an array inside components. Obviously if we ever do Components as Props that would need to be taken into account here - but I suspect that would be fine, each component would need to register internally which props can accept components.

  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md

ie if you forget to make children an array, and just put it flat in component args
@Marc-Andre-Rivet Marc-Andre-Rivet added this to the Dash v1.7 milestone Nov 26, 2019
if k != "children" and isinstance(v, Component):
raise TypeError(
"Component detected as a prop other than `children`\n" +
"Did you forget to wrap multiple `children` in an array?" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either a \n or whitespace after the end of the sentence

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call -> 4d96e0d

@Marc-Andre-Rivet
Copy link
Contributor

Marc-Andre-Rivet commented Nov 26, 2019

Diff in https://percy.io/plotly/dash/builds/3264807/view/203019307/1280?mode=diff&browser=firefox&snapshot=203019307 looks related to async / the behavior is fine but without eager_loading=True the graph displays locally with a noticeable delay, after the 1 appears on the devtools icon -- the screenshot occurs before the graph renders.

The important information is what the devtools are displaying. We could update the test to wait for svg.main-svg to be present.. otherwise we may get unstable results if/when the CI environment is a bit slower and allows for the graph to display before the snapshot.

Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃

@alexcjohnson alexcjohnson merged commit ffffce0 into dev Nov 27, 2019
@alexcjohnson alexcjohnson deleted the children-array-error branch November 27, 2019 15:20
@ohaibbq
Copy link

ohaibbq commented May 6, 2020

Hey y'all,

We're running into this exception while trying to use multiple props as PropType.node. React's docs suggest that if you have multiple pieces of content to dynamically add to a component, you should use your own props scheme rather than props.children. i.e. props.leftChildren and props.rightChildren.

Was this diff supposed to intentionally disallow this case? If not, I think we should add a PropType check to ensure that the prop type for k is not a PropType.node before raising this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants